package dao.oc_boat;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import entitybean.oc_boat.EntityBeanOc_Boat;
public class DaoImpl_Oc_Boat extends HibernateDaoSupport implements Dao_Oc_Boat{
	public void Insert_Oc_Boat(EntityBeanOc_Boat e)
	{
		this.getHibernateTemplate().save(e);
	}
	public void Update_Oc_Boat(EntityBeanOc_Boat e)
	{
		this.getHibernateTemplate().update(e);
	}
	public void Delete_Oc_Boat(EntityBeanOc_Boat e)
	{
		this.getHibernateTemplate().delete(e);
	}
	@SuppressWarnings("unchecked")
	public void Delete_Oc_Boat(String id)
	{
		List<EntityBeanOc_Boat> list=new ArrayList<EntityBeanOc_Boat>();
		list=this.getHibernateTemplate().find("from EntityBeanOc_Boat where id in ("+id+")");
		for(int i=0;i<list.size();i++)
		{
			EntityBeanOc_Boat e=list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);	
		}
		
		
	}
	@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Boat> Find_Oc_Boat_By_oc_boatkind(Integer oc_boatkind)
	{
		List<EntityBeanOc_Boat> list=new ArrayList<EntityBeanOc_Boat>();
		list=this.getHibernateTemplate().find("from EntityBeanOc_Boat where del='OFF' and oc_boatkind="+oc_boatkind);
		return list;
	}
	@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Boat> Find_Oc_Boat_By_oc_boatkind_Active()
	{
		List<EntityBeanOc_Boat> list=new ArrayList<EntityBeanOc_Boat>();
		list=this.getHibernateTemplate().find("from EntityBeanOc_Boat where del='OFF'");
		return list;
		
		
	}
	@SuppressWarnings("unchecked")
	public EntityBeanOc_Boat Find_Oc_Boat_By_oc_boatkind_By_id(String id)
	{
		List<EntityBeanOc_Boat> list=new ArrayList<EntityBeanOc_Boat>();
		list=this.getHibernateTemplate().find("from EntityBeanOc_Boat where id="+id);
		EntityBeanOc_Boat e=new EntityBeanOc_Boat();
		if(list.size()>0)
		{
			e=list.get(0);	
		}
		
		return e;
		
	}
	
}
